Ruby program to demonstrate the bitwise OR (|) operator

bookmark

num1=5
num2=3
res =0

res = num1 | num2;
print num1," | ", num2," = ",res,"\n"

num1=7
num2=4
res = num1 | num2;
print num1," | ", num2," = ",res

 


Output:

5 | 3 = 7
7 | 4 = 7